package study.domain.blog;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import lombok.Data;
import lombok.EqualsAndHashCode;
import study.domain.attachment.Attachment;

@Entity(name = "post_attachments")
@Data
@EqualsAndHashCode(of = { "post", "attachment" })
public class PostAttachment implements Serializable {

	private static final long serialVersionUID = -2134830480194844180L;

	@Id
	@ManyToOne
	@JoinColumn(name = "post_id")
	@org.hibernate.annotations.ForeignKey(name = "fk_post_attachments_post_id")
	private Post post;

	@Id
	@ManyToOne
	@JoinColumn(name = "attachment_id")
	@org.hibernate.annotations.ForeignKey(name = "fk_post_attachments_attachment_id")
	private Attachment attachment;
}
